/*This module is used to send ajax request*/

import axios from 'axios'
import {message} from "antd";

export default function ajax(url,data={},type='GET') {    //形参默认值

  return new Promise((resolve, reject)=>{

    let promise

    if(type==='GET'){
      promise = axios.get(url,{
        params: data
      })
    }else {
      promise = axios.post(url,data)
    }

    promise.then(response=>{
      resolve(response.data)
    }).catch(err=>{
      //不能用reject
      message.error('Request Error'+ err.message)
    })
  })
}








